j3deditor.bin.hierarchy
Class Vertex

java.lang.Object
  extended by j3deditor.bin.hierarchy.Vertex
Direct Known Subclasses:
VirtualVertex

public class Vertex
extends java.lang.Object

Represents a vertex of a polygonal mesh. Doesn't contain any vertex data, manipulates vertex data contained in J3DeGeometryArray referenced by this vertex.

Author:
Risto Seene
See Also:
J3DeGeometryArray

Field Summary
static int COORDINATE_VERTEX_STATE
          Positional coordinate state.
static int HIDDEN
          Specifies that this vertex is currently hidden.
 boolean inUse
          Used by various classes that manipulate the data of multiple vertices.
static int NORMAL
          Specifies that this vertex is in normal state.
static int SELECTED
          Specifies that this vertex is currently selected.
static int TEXTURE_VERTEX_STATE
          Texture coordinate state.
static int TRANSFORMABLE
          Specifies that this vertex can be transformed.
 
Constructor Summary
protected Vertex(J3DeGeometryArray g, int index)
          Creates an inastance of Vertex which represents index-th vertex in the specified J3DeGeometryArray.
 
Method Summary
 boolean equals(java.lang.Object o)
          Returns true if the Object o is of type Vertex and all of the positional coordinates of o are equal to the ones in this vertex.
 float getAlpha()
          Returns the alpha component of the color of this vertex if available.
 float[] getColor()
          Returns the color of this vertex.
 javax.vecmath.Point3f getCoordinate()
          Returns the positional coordinates of this vertex.
 float[] getCoordinates()
          Returns the positional coordinates of this vertex (X, Y, Z).
protected  J3DeGeometryArray getGeometry()
          Returns J3DeGeometryArray.
 int getIndex()
          Returns the index of this vertex.
 javax.vecmath.Vector3f getNormal()
          Returns the normal vector of this vertex.
 java.awt.Color getRGB()
          Returns the RGB color of this vertex.
 int getState(int type)
          Returns the state of this vertex.
 float getZ()
          Returns the Z-coordinate of this vertex.
 float getTex(int axis, int texCoordSet)
          Returns a texture coordinate of this vertex in the specified texture coordinate set.
 float[] getTexCoordinates(int texCoordSet)
          Returns texture coordinates of this vertex in the specified texture coordinate set.
 float getX()
          Returns the X-coordinate of this vertex.
 float getY()
          Returns the Y-coordinate of this vertex.
protected  void set(Vertex vertex)
          Copies all vertex data from the specified vertex to this vertex, including index and reference to J3DeGeometryArray.
 void setAlpha(float alpha)
          Sets the alpha component of the color of this vertex if vertex color has alpha component.
 void setColor(float[] color)
          Sets the color of this vertex.
 void setCoordinate(javax.vecmath.Point3f coordinates)
          Sets the positional coordinates of this vertex.
 void setCoordinates(float[] coordinates)
          Sets the positional coordinates of this vertex.
protected  void setData(Vertex vertex)
          Copies all vertex data from the specified vertex to this vertex, excluding index and reference to J3DeGeometryArray.
protected  void setIndex(int index)
          Sets the index of this vertex.
 void setNormal(javax.vecmath.Vector3f normal)
          Sets the normal vector of this vertex.
 void setRGB(java.awt.Color color)
          Sets the RGB color of this vertex.
 void setState(int state, int type)
          Changes the state of this vertex.
 void setZ(float z)
          Sets the Z coordinate of this vertex.
 void setTex(float coordinate, int axis, int texCoordSet)
          Sets a texture coordinate of this vertex.
 void setTexCoordinates(float[] coordinates, int texCoordSet)
          Sets the texture coordinates of this vertex.
 void setX(float x)
          Sets the X coordinate of this vertex.
 void setY(float y)
          Sets the Y coordinate of this vertex.
 java.lang.String toString()
          Returns the String representation of this vertex.
 void translate(float[] xyz)
          Translates this vertex.
 void translateZ(float z)
          Changes the Z coordinate of this vertex.
 void translateTex(float[] xy, int texCoordSet)
          Changes texture coordinates of this vertex.
 void translateX(float x)
          Changes the X coordinate of this vertex.
 void translateY(float y)
          Changes the Y coordinate of this vertex.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HIDDEN

public static final int HIDDEN
Specifies that this vertex is currently hidden.

See Also:
Constant Field Values

NORMAL

public static final int NORMAL
Specifies that this vertex is in normal state.

See Also:
Constant Field Values

SELECTED

public static final int SELECTED
Specifies that this vertex is currently selected.

See Also:
Constant Field Values

TRANSFORMABLE

public static final int TRANSFORMABLE
Specifies that this vertex can be transformed.

See Also:
Constant Field Values

COORDINATE_VERTEX_STATE

public static final int COORDINATE_VERTEX_STATE
Positional coordinate state.

See Also:
Constant Field Values

TEXTURE_VERTEX_STATE

public static final int TEXTURE_VERTEX_STATE
Texture coordinate state.

See Also:
Constant Field Values

inUse

public boolean inUse
Used by various classes that manipulate the data of multiple vertices.

Constructor Detail

Vertex

protected Vertex(J3DeGeometryArray g,
                 int index)
Creates an inastance of Vertex which represents index-th vertex in the specified J3DeGeometryArray.

Parameters:
g - J3DeGeometryArray the data of this vertex is in.
index - index of this vertex in J3DeGeometryArray
Method Detail

set

protected void set(Vertex vertex)
Copies all vertex data from the specified vertex to this vertex, including index and reference to J3DeGeometryArray.

Parameters:
vertex - vertex which data will be copied to this vertex

setData

protected void setData(Vertex vertex)
Copies all vertex data from the specified vertex to this vertex, excluding index and reference to J3DeGeometryArray.

Parameters:
vertex - vertex which data will be copied to this vertex

getIndex

public int getIndex()
Returns the index of this vertex.

Returns:
the index of this vertex

setIndex

protected void setIndex(int index)
Sets the index of this vertex.

Parameters:
index - new index

getCoordinates

public float[] getCoordinates()
Returns the positional coordinates of this vertex (X, Y, Z).

Returns:
the positional coordinates of this vertex

getCoordinate

public javax.vecmath.Point3f getCoordinate()
Returns the positional coordinates of this vertex.

Returns:
the positional coordinates of this vertex

getX

public float getX()
Returns the X-coordinate of this vertex.

Returns:
the X-coordinate of this vertex

getY

public float getY()
Returns the Y-coordinate of this vertex.

Returns:
the Y-coordinate of this vertex

getZ

public float getZ()
Returns the Z-coordinate of this vertex.

Returns:
the Z-coordinate of this vertex

getTexCoordinates

public float[] getTexCoordinates(int texCoordSet)
Returns texture coordinates of this vertex in the specified texture coordinate set. Number of coordinate axes depends on the type of texture coordinates.

Parameters:
texCoordSet - texture coordinate set
Returns:
texture coordinates of this vertex in the specified texture coordinate set

getTex

public float getTex(int axis,
                    int texCoordSet)
Returns a texture coordinate of this vertex in the specified texture coordinate set.

Parameters:
axis - coordinate axis: S, T, R or Q
texCoordSet - texture coordinate set
Returns:
a texture coordinate of this vertex in the specified texture coordinate set

setState

public void setState(int state,
                     int type)
Changes the state of this vertex.

Parameters:
state - HIDDEN, NORMAL, SELECTED or TRANSFORMABLE
type - state type: COORDINATE_VERTEX_STATE or TEXTURE_VERTEX_STATE

getState

public int getState(int type)
Returns the state of this vertex.

Parameters:
type - state type: COORDINATE_VERTEX_STATE or TEXTURE_VERTEX_STATE
Returns:
the state of this vertex

setCoordinates

public void setCoordinates(float[] coordinates)
Sets the positional coordinates of this vertex.

Parameters:
coordinates - new position of this vertex

setCoordinate

public void setCoordinate(javax.vecmath.Point3f coordinates)
Sets the positional coordinates of this vertex.

Parameters:
coordinates - new position of this vertex

setTexCoordinates

public void setTexCoordinates(float[] coordinates,
                              int texCoordSet)
Sets the texture coordinates of this vertex.

Parameters:
coordinates - new texture coordinates
texCoordSet - texture coordinate set

setTex

public void setTex(float coordinate,
                   int axis,
                   int texCoordSet)
Sets a texture coordinate of this vertex.

Parameters:
coordinate - new texture coordinate
axis - coordinate axis: S, T, R or Q
texCoordSet - texture coordinate set

translate

public void translate(float[] xyz)
Translates this vertex.

Parameters:
xyz - change of position on each axis

translateTex

public void translateTex(float[] xy,
                         int texCoordSet)
Changes texture coordinates of this vertex.

Parameters:
xy - change of coordinates on S and T axis
texCoordSet - texture coordinate set

setX

public void setX(float x)
Sets the X coordinate of this vertex.

Parameters:
x - new X coordinate

translateX

public void translateX(float x)
Changes the X coordinate of this vertex.

Parameters:
x - change of position on X axis

setY

public void setY(float y)
Sets the Y coordinate of this vertex.

Parameters:
y - new Y coordinate

translateY

public void translateY(float y)
Changes the Y coordinate of this vertex.

Parameters:
y - change of position on Y axis

setZ

public void setZ(float z)
Sets the Z coordinate of this vertex.

Parameters:
z - new Z coordinate

translateZ

public void translateZ(float z)
Changes the Z coordinate of this vertex.

Parameters:
z - change of position on Z axis

equals

public boolean equals(java.lang.Object o)
Returns true if the Object o is of type Vertex and all of the positional coordinates of o are equal to the ones in this vertex.

Overrides:
equals in class java.lang.Object
Parameters:
o - the Object with which the comparison is made
Returns:
true if the Object o is of type Vertex and all of the positional coordinates of o are equal to the ones in this vertex

toString

public java.lang.String toString()
Returns the String representation of this vertex.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of this vertex

getGeometry

protected J3DeGeometryArray getGeometry()
Returns J3DeGeometryArray.

Returns:
J3DeGeometryArray

getNormal

public javax.vecmath.Vector3f getNormal()
Returns the normal vector of this vertex.

Returns:
the normal vector of this vertex

setNormal

public void setNormal(javax.vecmath.Vector3f normal)
Sets the normal vector of this vertex.

Parameters:
normal - normal vector

getColor

public float[] getColor()
Returns the color of this vertex.

Returns:
the color of this vertex

setColor

public void setColor(float[] color)
Sets the color of this vertex.

Parameters:
color - R, G and B if COLOR_3
R, G, B and A if COLOR_3

getRGB

public java.awt.Color getRGB()
Returns the RGB color of this vertex.

Returns:
the RGB color of this vertex

setRGB

public void setRGB(java.awt.Color color)
Sets the RGB color of this vertex.

Parameters:
color - Color with R, G and B components

getAlpha

public float getAlpha()
Returns the alpha component of the color of this vertex if available.

Returns:
the alpha component of the color of this vertex if available

setAlpha

public void setAlpha(float alpha)
Sets the alpha component of the color of this vertex if vertex color has alpha component.

Parameters:
alpha - new value of alpha component